<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chkGametype = chkGametype($gametype);
$chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
$show5N = getShow35($gametype);
unset($chk);
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$pg = $g_gametype_3d[$gametype]['pg'];
$u_subsidary = get_user($curruser['id'], $gametype);
$ui = new UI_3D(true);
$tpl = new Template2();
$conf = new Config();
$snow_open = $conf->get("snow_open_{$tbl}");
if ($snow_open == "0" || $u_subsidary['snow_open'] == "0")
{
    $ui->showErrorPage("{$tblName}大股东操盘模式已关闭！");
    exit();
}
if ($curruser['acl'] != 255)
{
    $userlist = GetUserList($curruser['id']);
    if ($userlist == "")
    {
        $ui->showErrorPage("<p>还没有建立会员！</p>");
        exit();
    }
}
if ($chkGametype == 3)
{
    include_once( "class_5h/RateConfig_5h.php" );
    include_once( "class_5h/SRate_5h.php" );
    $RateConfig_3d = new RateConfig_5h($gametype);
    $tempArray = array();
    $tempOrderArr = array();
    $tempNoQuickArr = array();
    $_5hFlag = true;
    if (20 < $gametype)
    {
        $_5hFlag = false;
        $_8hFlag = true;
    }
    else
    {
        $_5hFlag = true;
        $_8hFlag = false;
    }
}
elseif ($chkGametype == 4)
{
    include_once( "class_sb/RateConfig_sb.php" );
    include_once( "class_sb/SRate_sb.php" );
    $RateConfig_3d = new RateConfig_sb($gametype);
    $tempArray = array();
    $tempOrderArr = array();
    $tempNoQuickArr = array();
    $_5hFlag = false;
	$_8hFlag = false;
}
else
{
    include_once( "class_3d/RateConfig_3d.php" );
    include_once( "class_3d/SRate_3d.php" );
    $RateConfig_3d = new RateConfig_3d($gametype);
    $tempArray = array("r3" => "r3", "r3p" => "r3p", "rcmp" => "rcmp");
    $tempOrderArr = array("r1" => "r1", "r1p" => "r1p", "g3" => "g3", "g6" => "g6");
    $tempNoQuickArr = array("r2" => "r2", "r2p" => "r2p");
    $_5hFlag = false;
    $_8hFlag = false;
}
switch ($show3D3S)
{
    case 0 :
        $SRate_3d = new SRate_3d($gametype);
        break;
    case 1 :
        $SRate_3d = new SRate_3s($gametype);
        break;
    case 2 :
        $SRate_3d = new SRate_5h($gametype);
        break;
	case 3 :
        $SRate_3d = new SRate_sb($gametype);
        break;
}
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$split = 1;
$disk = 0;
$order = 0;
$playtype = getvar("playtype");
$id = getvar("id");
$bid = getvar("bid");
$ratemod = 0;
if ($id == "")
{
    $showday = date("Y-m-d");
    $lottoData = $SRate_3d->getLotto3DByDate($showday);
}
else
{
    $id = intval($id);
    $lottoData = $SRate_3d->getLotto3DById($id);
    $showday = $lottoData['open'];
}
if ($lottoData == "")
{
    $ui->showErrorPage("目前没有{$tblName}可以下注期数！", true);
    exit();
}
unset($RateConfig_3d->playtypeArr02['all']);
$playtype = isset($RateConfig_3d->playtypeArr02[$playtype]) ? $playtype : "r1";
if ($bid != "")
{
    $fieldsArr = array($bid);
}
else
{
    $fieldsArr = $RateConfig_3d->playGroupArr02[$playtype];
}
$bidstr = "";
if ($bid == "")
{
    $bidstr = "";
}
else
{
    $bid == intval($bid);
    if (!in_array($bid, $RateConfig_3d->playGroupArr02[$playtype]))
    {
        diemsg("{$tblName}玩法资料错误。");
    }
    $bidstr = "&bid=" . $bid;
    $tpl->set("bid", $bid);
}
$menu_list_url = "";
$tempUrl = "op.php?op=subsidary&fp=snow_3d&gametype={$gametype}&playtype=";
$tempArr = array();
if ($_5hFlag)
{
    $xyid = 1;
    $tempArr[] = "<th width='10%'>" . getOptionXYList($xyid, true, "", "xyid", "xyid") . "<span id='noxystr' class='noneRateRecord'>单一盘</span></th>";
}
if ($show5N)
{
    $jsFuname = "_n5";
    $jsFunameFlag = "true";
}
else
{
    $jsFuname = "";
    $jsFunameFlag = "false";
}
foreach ($RateConfig_3d->playtypeArr02 as $key => $val)
{
    $showUrl = $tempUrl . $key;
    if ($playtype == $key)
    {
        $tempClass = " class=\"cbig\"";
    }
    else
    {
        $tempClass = "";
    }
    $tempArr[] = "<th {$tempClass} id='myThBar{$key}' ><a href=\"javascript:clickTitle('{$key}');\">{$val}</a><br />(<span style='color:#cc0000' id='spanPageAmount{$key}'></span>)</th>";
}
$menu_list_url = implode("", $tempArr);
switch ($show3D3S)
{
    case 0 :
        $stopbet_3d = $conf->get("stopbet_{$tbl}");
        if ($stopbet_3d == "0000")
        {
            $stopbet_3d = "2359";
        }
        $tempStrInt = false;
        break;
    case 1 :
    case 2 :
	case 3 :
        $tempStrInt = strtotime($lottoData['stopbet']);
        break;
}
if ($tempStrInt == false)
{
    $h = substr($stopbet_3d, 0, 2);
    $m = substr($stopbet_3d, 2);
    $tempStr = "{$showday} {$h}:{$m}:00";
    $timetamp = systime();
    $timetamplimit = strtotime($tempStr) - $timetamp;
}
else
{
    $timetamp = systime();
    $timetamplimit = $tempStrInt - $timetamp;
}
$disabledbet = "";
if ($timetamplimit < 1)
{
    $disabledbet = "disabled=\"disabled\"";
}
$tpl->load("main", "snow_3d.htm");
$quickBtnDisplay = "";
if (isset($tempOrderArr[$playtype]))
{
    $order = 2;
}
if (isset($tempArray[$playtype]))
{
    $quickBtnDisplay = "&nbsp;";
}
if (isset($tempNoQuickArr[$playtype]))
{
    $btnQuickStr = " [ <font style=\"color:blue;font-weight:bold;\">设定</font>]&nbsp;&nbsp;&nbsp;";
}
else
{
    $btnQuickStr = "";
}
$reloadCK = $show3D3S ? "20" : "30";
$tpl->set(array("playtype" => $RateConfig_3d->playtypeArr02[$playtype], "menu_list_url" => $menu_list_url, "lotto_id_3d" => $lottoData['id'], "round" => $lottoData['round'], "open" => $lottoData['open'], "timetamp" => $timetamp, "timetamplimit" => $timetamplimit, "playtypestr" => $playtype, "split" => $split, "order" => $order, "disk" => $disk, "ratemod" => $ratemod, "disabled" => $disabledbet, "quickBtnDisplay" => $quickBtnDisplay, "gametype" => $gametype, "gametypeStr" => $tblName, "btnQuickStr" => $btnQuickStr, "reloadCK" => $reloadCK, "jsLang" => $g_conf['language'], "jsFuname" => $jsFuname));
if ($conf->get("protect_start_{$tbl}") == "1")
{
    $btnSetConfFly = "true";
}
else
{
    $btnSetConfFly = "false";
}
$jslink = "<script src=\"js_3d/jquery-ui-1.8.11.custom.min.js\"></script>\n";
$jslink .= "<script src=\"js_3d/showRateRecord.js\"></script>\n";
$jslink .= "<script src=\"js_3d/js3d.js\"></script>\n";
$jslink .= "<script>";
$jslink .= "var __roundID = " . $lottoData['id'] . ";";
$jslink .= "var __reloadCK = 0;";
$jslink .= "var now = new Date(1000 * {$timetamp});";
$jslink .= "var timestap = {$timetamplimit};";
$jslink .= "var myGlobalVal = {};";
$jslink .= "myGlobalVal.gametype = '{$gametype}';";
$jslink .= "myGlobalVal.lotto_id_3d = " . $lottoData['id'] . ";";
$jslink .= "myGlobalVal.playtypestr = '{$playtype}';";
$jslink .= "myGlobalVal.open = '" . $lottoData['open'] . "';";
$jslink .= "myGlobalVal.reloadCK = '{$reloadCK}';";
$jslink .= "myGlobalVal.jsFuname = {$jsFunameFlag};";
$jslink .= "myGlobalVal.btnSetConfFly = {$btnSetConfFly};";
$jslink .= "var _playtype = 'r1';";
if ($_5hFlag || $_8hFlag)
{
    $jslink .= "var _myHeader = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别1</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别2</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别3</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
}
else
{
    $jslink .= "var _myHeader = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
}
$jslink .= "</script>";
$jsScr = "";
if ($_8hFlag)
{
    $jsScr = "8h";
}
if ($gametype == 24)
{
    $jsScr = "pk10";
}
$jslink .= "<script src=\"scr{$pg}/" . $g_conf['language'] . "/snow" . $jsScr . ".js\"></script>\n";
if (intval($conf->get("myCssChange_3d")))
{
    $jslink .= "<style>input.btnplus, input.btnmin{ \tcolor: #000000; \tbackground-color: #ffffff; \tborder: 1px solid #c8c8c8; \ttext-indent: 2px; \tcursor: pointer; \tbackground-image: url(core/tpl/k2/image/bgGray02.png); \tbackground-repeat: repeat-x; \tbackground-position: center; }</style>";
    $tpl->set("myCssChange_3dCHKSTR", "checked");
}
$ui->set("jslink", $jslink);
if($gametype<25)
{
	$number = intval(getvar("number"));
	if ($number == "")
	{
		$number = 1;
	}
	$OK = two_long($gametype, $flag = $number == 1 ? true : false, 3);
	$g_betname_3or5 = judge_type($gametype, false);
	foreach ($OK as $key => $value)
	{
		$sd = array (1 => "<font class=text01>单</font>", 2 => "<font class=text02>双</font>");
		$bs = array (1 => "<font class=text01>大</font>", 2 => "<font class=text02>小</font>");
		$color = array (1 => "<font color=\"red\">红</font>", 2 => "<font color=\"blue\">蓝</font>", 3 => "<font color=\"green\">绿</font>");
		$four = array (1 => "<font color=\"saddlebrown\">福</font>", 2 => "<font color=\"dimgray\">禄</font>", 3 => "<font color=\"darkorange\">寿</font>", 4 => "<font color=\"5200A0\">喜</font>");
		$position = array (1 => "<font color=\"saddlebrown\">东</font>", 2 => "<font color=\"dimgray\">南</font>", 3 => "<font color=\"darkorange\">西</font>", 4 => "<font color=\"5200A0\">北</font>");
		$three = array (1 => "<font color=\"red\">中</font>", 2 => "<font color=\"blue\">发</font>", 3 => "<font color=\"green\">白</font>");
		$animal = array (1 => "<font class=text01>龙</font>", 2 => "<font class=text02>虎</font>");
		$pc = array (1 => "<font class=text01>质</font>", 2 => "<font class=text02>合</font>");
		$key_change = substr($key, 0, 0 - 2);
		$last = $key[strlen($key) - 1];
		if ($g_gametype_3d[$gametype]['type'] != 3)
		{
			$bettype = array (1 => "单双", 2 => "大小", 3 => "质合");
			$median = array (1 => "第五球", 2 => "第四球", 3 => "第三球", 4 => "第二球", 5 => "第一球");
			foreach ($bettype as $key2 => $value2)
			{
				foreach ($median as $key3 => $value3)
				{
					foreach ($g_betname_3or5 as $key4 => $value4)
					{
						if (( substr($key, 0, 0 - 4) == $key2 && $key[strlen($key) - 3] == $key3 ) && ( $value4 == $value3 . $value2 ))
						{
							$key_change = $key4;
						}
					}
				}
			}
		}
		foreach ($g_betname_3or5 as $key1 => $value1)
		{
			if ($key_change == $key1)
			{
				if ($g_gametype_3d[$gametype]['type'] == 3)
				{
					$type = array (
						1 => $sd,
						2 => $bs,
						3 => $bs,
						4 => $sd,
						5 => $gametype == 20 ? $color : $three,
						6 => $gametype == 20 ? $four : $position,
						7 => $sd,
						8 => $bs,
						9 => $bs,
						18 => $animal
					);
					$show[$value1 . "&nbsp;-&nbsp;" . $type[substr($key, 0, 0 - 4)][$last]] = $value;
				}
				else
				{
					$type = array (
						"单双" => $sd,
						"大小" => $bs,
						"质合" => $pc,
						"虎和" => $animal
					);
					$show[$value1 . "&nbsp;-&nbsp;" . $type[substr($value1, 0 - 4)][$last]] = $value;
				}
			}
		}
	}

	$display = "<div>";
	$display .= "<table class=\"tblMy3D\" style=\"width:100px;\">";
	$display .= "<tr class=\"bgImg_{$gametype}\">";
	$display .= "<td colspan=\"2\" align=\"center\">两面长龙排行</td></tr>";
	$display .= "<tr class=\"bgImg_{$gametype}\" align=\"center\"><td colspan=\"2\" nowrap>";
	$display .= "<label><input type=\"radio\" onclick=\"check_box(1)\"" . ( $flag ? "checked" : "" ) . ">出球</label>&nbsp;&nbsp;";
	$display .= "<label><input type=\"radio\" onclick=\"check_box(2)\"" . ( $flag ? "" : "checked" ) . ">无出</label></td></tr>";
	if (isset($show))
	{
		arsort($show);
		foreach ($show as $key => $value)
		{
			$display .= "<tr class=\"left_td2\">";
			$display .= "<td nowrap style=\"font-weight:bold; color:black; text-align:right\">&nbsp;" . $key . "</td>";
			$display .= "<td nowrap>" . $value . "&nbsp;期&nbsp;</td></tr>";
		}
	}
	else
	{
		$display .= "<tr class=\"left_td2\" align=\"center\">";
		$display .= "<td nowrap>无资料</td>";
		$display .= "<td nowrap>无资料</td></tr>";
	}
	$display .= "</table></div>";
	$tpl->set("display", $display);
}
$ui->header();
$tpl->show("main");
$ui->footer();
?>